homeApp.service("userService",function(){
	this.isPc = function(){
	    var userAgentInfo = navigator.userAgent;  
	    var Agents = new Array("Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod");    
	    var flag = true;    
	    for (var v = 0; v < Agents.length; v++) {    
	        if (userAgentInfo.indexOf(Agents[v]) > 0) { flag = false; break; }    
	    }    
	    return flag;      
	}

	this.checkPhoneNum = function(num){
		if("undefined" == typeof num) return false;

		var reg = /^[1]{1}\d{10}$/;
		if(!reg.test(num.toString())){
			return false;
		}else{
			return true;
		}
	}

	this.checkPassword = function(password){
		if("undefined" == typeof password) return false;

		var reg = /^[a-zA-Z0-9_]{6,}$/;
		if(!reg.test(password.toString())){
			return false;
		}else{
			return true;
		}
	}

	this.setLocalStorage = function(key,value){

		if(!key || "undefined" == typeof key){
			console.log("localStorage key is undefined");
			return false;
		}
		if(!value || "undefined" == typeof value){
			console.log("localStorage value is undefined");
			return false;
		};

		var jsonStr = JSON.stringify({
			value:value,
			'createtime': new Date().valueOf(),
			'expire': 3*24*60*60*1000
		});

		localStorage.setItem(key,jsonStr);

	}

	this.getLocalStorage = function(key){
		var value = JSON.parse(localStorage.getItem(key)).value;
		return value;
	}

	this.userIsLogin = function(){
		var uuidStr = localStorage.getItem("start-uuid");

		if( uuidStr == null || "undefined" == typeof uuidStr){
			return false;
		}else{
			var uuid = JSON.parse(uuidStr);
			var now = parseInt(new Date().valueOf());

			if( (now-parseInt(uuid.createtime)) >= parseInt(uuid.expire) ){
				localStorage.removeItem("start-uuid");
				localStorage.removeItem("start-name");
				localStorage.removeItem("start-pic");
				return false;
			}else{
				return true;
			}
		}
	}
})